//
//  ThreeViewController.m
//  翻转效果
//
//  Created by Lucifer on 15-5-19.
//  Copyright (c) 2015年 xuxzhou. All rights reserved.
//

#import "ThreeViewController.h"
#import "QRCodeGenerator.h"

@interface ThreeViewController ()
@property(nonatomic,strong)UIImageView * myselfCode;


@end

@implementation ThreeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"AboutMySelf";
    UIBarButtonItem * rightBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showscanningPage)];
    self.navigationItem.rightBarButtonItem = rightBtn;
    
    _myselfCode=[[UIImageView alloc]initWithFrame:CGRectMake(30, 30, CGRectGetWidth(self.view.frame)-60, CGRectGetWidth(self.view.frame)-60)];
    [self.view addSubview:_myselfCode];
    [self createErWeiMa];
}

- (void)createErWeiMa{
    NSDictionary * myselfDictionary = @{@"姓名":@"周英许",
                                        @"电话":@"13071805991",
                                        @"email":@"zhouyingxuWork@163.com",
                                        @"应聘职位":@"iOS开发工程师",
                                        @"微信号":@"MissYingXuZhou",
                                        @"QQ":@"1451365843"
                                        };
    _myselfCode.image=[QRCodeGenerator qrImageForString: [self DataTOjsonString:myselfDictionary] imageSize:_myselfCode.bounds.size.width];
}

-(void)showscanningPage{



}
-(NSString*)DataTOjsonString:(id)object
{
    NSString *jsonString = nil;
    NSError *error;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object
                                                       options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
                                                         error:&error];
    if (! jsonData) {
        NSLog(@"Got an error: %@", error);
    } else {
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    }
    return jsonString;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
